var t = new (require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../http/directBuyApi")).default)(), e = require("../../utils/tool").toastToPage;

Component({
    properties: {
        productStatus: {
            type: Number,
            value: 0,
            observer: function(t) {
                1 == t ? this.getSellStatus() : 2 == t ? this.setData({
                    text: "暂无购买资格"
                }) : 3 == t ? this.setData({
                    text: "还有机会，有人拍下未付款"
                }) : 4 == t ? (this.setData({
                    text: "已售罄"
                }), this.getArrivalStatus()) : 5 == t && this.setData({
                    text: "已下架"
                });
            }
        },
        carCount: {
            type: Number
        },
        sellTime: {
            type: String
        },
        productId: {
            type: String
        }
    },
    data: {
        text: "",
        arrivalStatus: !1,
        sellStatus: !1
    },
    methods: {
        tappingBuy: function() {
            this.triggerEvent("showBuy", {
                isShow: !0
            });
        },
        tappingCar: function() {
            this.triggerEvent("showCar", {
                isShow: !1
            });
        },
        toCar: function() {
            wx.navigateTo({
                url: "/pages/car/car"
            });
        },
        getSellStatus: function() {
            var e = this;
            t.noticeStatus(3, this.properties.productId).then(function(t) {
                e.setData({
                    sellStatus: t.data.noticeStatus
                });
            }).catch(function(t) {
                wx.hideLoading();
            });
        },
        getArrivalStatus: function() {
            var e = this;
            t.noticeStatus(1, this.properties.productId).then(function(t) {
                e.setData({
                    arrivalStatus: t.data.noticeStatus
                }), wx.hideLoading();
            }).catch(function(t) {
                wx.hideLoading();
            });
        },
        subscribeSell: function() {
            if (!this.data.sellStatus) {
                var i = this;
                wx.requestSubscribeMessage({
                    tmplIds: [ "7gRq-cZY58xMKjX4zhVgW1gryHKxl71QmMchnBbVqkQ" ],
                    success: function(a) {
                        "accept" == a["7gRq-cZY58xMKjX4zhVgW1gryHKxl71QmMchnBbVqkQ"] ? (wx.showLoading({
                            title: "加载中",
                            mask: !0
                        }), t.sellNoctice(i.properties.productId).then(function(t) {
                            wx.hideLoading(), i.getSellStatus(), e("订阅成功");
                        }).catch(function(t) {
                            wx.hideLoading();
                        })) : e("取消订阅");
                    },
                    fail: function(t) {
                        e('请去"设置-消息订阅"开启消息通知');
                    },
                    complete: function(t) {}
                });
            }
        },
        subscribeArrival: function() {
            var i = this;
            wx.requestSubscribeMessage({
                tmplIds: [ "vxx2-hSYw5A9_WApgxcSe0jSiam5tXRwnH4YwzMJ2lo" ],
                success: function(a) {
                    "accept" == a["vxx2-hSYw5A9_WApgxcSe0jSiam5tXRwnH4YwzMJ2lo"] ? (wx.showLoading({
                        title: "加载中",
                        mask: !0
                    }), t.arrivalNotice(i.properties.productId).then(function(t) {
                        wx.hideLoading(), i.getArrivalStatus(), e("订阅成功");
                    }).catch(function(t) {
                        wx.hideLoading();
                    })) : e("取消订阅");
                },
                fail: function(t) {
                    e('请去"设置-消息订阅"开启消息通知');
                },
                complete: function(t) {}
            });
        }
    }
});